package graphics;

import java.awt.Color;

import java.awt.*;
import java.util.Vector;

import javax.swing.JLabel;

import objects.Asteroid;

import ship.Ship;
import ship.ShipConstants;
import structure.SObject;

import main.Game;

public class MiniLabel extends JLabel {
	private int width = 150;
	private int height= 150;

	public MiniLabel() {

	}

	public void paint(Graphics g) {
		MaxGraphics mg = new MaxGraphics((Graphics2D) g);
		g.setColor(Color.black);
		g.fillRect(0, 0, width, height);
		Ship s = Game.game.getShip();

		mg.translate(-(s.getX() / width) + (width / 2), -(s.getY() / height) + (height / 2));

		mg.setColor(Color.red);

		mg.fillOval(s.getX() / width, s.getY()/ height, 2, 2);

		double minX = s.getX() - (s.getSensorRadius() * ShipConstants.SENSOR_MOD);
		double minY = s.getY() - (s.getSensorRadius() * ShipConstants.SENSOR_MOD);

		double maxX = s.getX() + (s.getSensorRadius() * ShipConstants.SENSOR_MOD);
		double maxY = s.getY() + (s.getSensorRadius() * ShipConstants.SENSOR_MOD);

		double innerWidth = maxX - minX;
		double innerHeight = maxY - minY;

		Vector<SObject> v = new Vector<SObject>(Game.game.getMini());
		for(SObject obj : v) {
			if(obj instanceof Asteroid) {
				mg.setColor(Color.WHITE);
				mg.fillOval((((obj.getX() - minX) / innerWidth) * width) - (width / 2), (((obj.getY() - minY) / innerHeight) * height) - (height / 2), 1, 1);
			}
			if(obj instanceof Ship) {
				if(((Ship) obj).getPlayer() != Game.game.getPlayer())  {
					mg.setColor(Color.RED);
					mg.fillOval((((obj.getX() - minX) / innerWidth) * width) - (width / 2), (((obj.getY() - minY) / innerHeight) * height) - (height / 2), 2, 2);
				}
			}
		}

	}





}
